package com.javacoo.xservice.base.support.lock.config;

import java.util.Map;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import com.javacoo.xservice.base.bean.LockBean;
import com.javacoo.xservice.base.support.lock.Lock;

/**
 * 接口加锁参数配置
 * <p>说明:参数为空时为方法级加锁,否则是参数级加锁</p>
 * <li>格式=> app.config.lock.lockParamMap[(版本号_)接口名称].secondTimeout=60</li>
 * <li>格式=> app.config.lock.lockParamMap[(版本号_)接口名称].params=['参数名1'],['参数名2']...</li>
 * @author duanyong@jccfc.com
 * @date 2021/3/4 15:15
 */
@Configuration
@ConfigurationProperties(prefix = LockConfig.PREFIX)
@ConditionalOnProperty(prefix = LockConfig.PREFIX, value = LockConfig.ENABLED, matchIfMissing = true)
public class LockConfig {
    public static final String PREFIX = "app.config.lock";
    public static final String ENABLED = "enabled";
    /** 默认实现:,默认值*/
    public static final String DEFAULT_IMPL= "default";
    /**是否可用*/
    private String enabled = ENABLED;
    /**超时时间:默认60秒*/
    private Integer secondTimeout = Lock.TIMEOUT_SECOND;
	/**接口加锁参数配置Map*/
	private Map<String, LockBean> lockParamMap;
    /**实现*/
    private String impl = DEFAULT_IMPL;

    public String getEnabled() {
        return enabled;
    }

    public void setEnabled(String enabled) {
        this.enabled = enabled;
    }

    public Integer getSecondTimeout() {
        return secondTimeout;
    }

    public void setSecondTimeout(Integer secondTimeout) {
        this.secondTimeout = secondTimeout;
    }

    public Map<String, LockBean> getLockParamMap() {
        return lockParamMap;
    }

    public void setLockParamMap(Map<String, LockBean> lockParamMap) {
        this.lockParamMap = lockParamMap;
    }

    public String getImpl() {
        return impl;
    }

    public void setImpl(String impl) {
        this.impl = impl;
    }
}
